def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True

def closest_prime(words):
    numbers = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9}

    num_str = ""
    for word in words:
        if word in numbers:
            num_str += str(numbers[word])
        else:
            print("Wrong input")
            return

    num = int(num_str)

    if len(num_str) != 3:
        print("Wrong input")
        return

    while not is_prime(num):
        num += 1

    print(num)

words = input().split()
closest_prime(words)
